package com.shujia.day16.sjms.oneobj2;

public class Student {
    private static Student student = null;

    String name;

    private Student(String name) {
        this.name = name;
    }

    public static synchronized Student getStudent(String name){
        if (student == null){
            student = new Student(name);
        }else {
            student.name = name;
            return student;
        }

        return student;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                '}';
    }
}
